# Maintainer: Tim Meusel <tim@bastelfreak.de>
# Contributor: Christian Rebischke <chris.rebischke@archlinux.org>
# Contributor: Mario Finelli <mario at finel dot li>
# Contributor: Tim Meusel <tim@bastelfreak.de>

_gemname='domain_name'
pkgname="ruby-${_gemname}"
pkgver=0.5.20190701
pkgrel=4
pkgdesc='Domain Name manipulation library for Ruby'
arch=('any')
url='https://github.com/knu/ruby-domain_name'
license=('BSD' 'MPL2')
makedepends=('ruby-rdoc' 'ruby-bundler')
checkdepends=('ruby-rake' 'ruby-minitest' 'ruby-test-unit')
depends=('ruby' 'ruby-unf')
options=(!emptydirs)
source=("${url}/archive/v${pkgver}/${pkgname}-v${pkgver}.tar.gz")
sha512sums=('d2aaa3236177cd196fde6e48acfde4c9858c7c7acd25a5e7fbdf8f30e2f71ca144ba1036e3820e2a8870877d259c96b948650464171a69208cbc947d9fa663f3')

prepare() {
  cd "${srcdir}/${pkgname}-${pkgver}"

  # allow latest dependencies
  sed --in-place 's|~>|>=|g' "${_gemname}.gemspec"

  # we built with a tar ball, so `git` won't wwork
  sed --in-place 's|git ls-files|find|' "${_gemname}.gemspec"
}

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  gem build "${_gemname}.gemspec"
}

check() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  rake test
}

package() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  local _gemdir="$(gem env gemdir)"
  gem install --verbose --ignore-dependencies --no-user-install --install-dir "${pkgdir}/${_gemdir}" --bindir "${pkgdir}/usr/bin" "${_gemname}-${pkgver}.gem"

  install -Dm 644 LICENSE.txt -t "${pkgdir}/usr/share/licenses/${pkgname}/"

  rm -rf "${pkgdir}/${_gemdir}/cache"
}

# vim: ts=2 sw=2 et:
